package com.mini.mysql.repository;

import com.mini.mysql.model.BusinessPlanSitePageR;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 项目名称：mini-data-es
 * 类 名 称：BusinessPlanSitePageRRepository
 * 类 描 述：TODO
 * 创建时间：2021/4/2 上午11:02
 * 创 建 人：zhanghuiying
 */
@Repository
public interface BusinessPlanSitePageRRepository extends JpaRepository<BusinessPlanSitePageR,Long>, JpaSpecificationExecutor<BusinessPlanSitePageR> {

    @Query(value = "select * from business_plan_site_page_r " +
            " where plan_site in (?1)",nativeQuery = true)
    List<BusinessPlanSitePageR> findByPlanSite(List<Integer> planId);

    @Query(value = "SELECT DISTINCT a.lesson_site, a.plan_site , a.plan_name  from business_plan_site_page_r a \n" +
            "    inner JOIN bussiness_page_info b\n" +
            "    on a.page_site=b.id\n" +
            "    where a.plan_site=?1 or a.plan_name =?1 or a.page_site=?1 or b.page_name=?1",nativeQuery = true)
    List<Object[]> selectByPlanListByKey(String key);
}
